from dao import ma
from marshmallow import fields, validate

"""
 数据库到json的序列化
https://marshmallow.readthedocs.io/en/stable/marshmallow.schema.html

"""


class UserOutSchema(ma.Schema):
    class Meta:
        fields = ("id", "name", "address")


class UserInSchema(ma.Schema):
    name = fields.Str()
    status = fields.Str(validate=validate.OneOf(["0", "1"]))

    class Meta:
        fields = ("id", "address")
        exclude = ("id",)
